from django.db import models

# Create your models here.
from django.db.models import Model, CharField, ForeignKey, IntegerField, DateField, DateTimeField


class User(Model):

    user = CharField(max_length=200, null=False, verbose_name="用户账号")
    pwd = CharField(max_length=200, null=False, verbose_name="用户密码")
    tel = CharField(max_length=200, null=False, verbose_name="用户电话")


class Token(Model):

    user = ForeignKey("User", on_delete=models.CASCADE)
    token = CharField(max_length=100, null=True, verbose_name="用户登录token")


class Book(Model):

    name = CharField(max_length=200, null=False, verbose_name="书名")
    author = ForeignKey("User", null=True, on_delete=models.CASCADE, verbose_name="书籍作者")
    page = IntegerField(verbose_name="图书页数")
    pub_time = DateField(auto_now_add=True)
    ctime = DateTimeField(auto_now_add=True)

